<template>
  <div class="footers">
    <div
      class="good"
      v-for="(value, index) in goods"
      :key="index"
      :class="{ activeStyle: $route.name === value.name && index === active }"
      @click="i(index)"
    >
      <span class="icons" :class="['iconfont', value.icon]"></span>
      <span class="texts">{{ value.text }}</span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      goods: [
        {
          icon: "icon-jia1",
          text: "首页",
          name: "index",
        },
        {
          icon: "icon-huiyuan",
          text: "会员",
          name: "info",
        },
        {
          icon: "icon-gouwuche",
          text: "购物车",
          name: "shop",
        },
        {
          icon: "icon-1-1",
          text: "搜索",
          name: "serach",
        },
      ],
      active: 0,
    };
  },

  mounted() {},

  methods: {
    i(index) {
      this.active = index;
      if (index == 0) {
        this.$router.push({ name: "index" }).catch(() => {});
      } else if (index == 1) {
        this.$router.push({ name: "info" }).catch(() => {});
      } else if (index == 2) {
        this.$router.push({ name: "shop" }).catch(() => {});
      } else if (index == 3) {
        this.$router.push({ name: "search" }).catch(() => {});
      }
    },
  },
};
</script>

<style lang="less" scoped>
@import url("//at.alicdn.com/t/font_2621049_2wy8jxt71aw.css");
.footers {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50/375 * 100vw;
  display: flex;
  border-top: 1px solid #efefef;
  justify-content: space-around;
  align-items: center;
  background-color: white;
  .good {
    display: flex;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
  }
  .activeStyle {
    color: #39b54a;
  }
  .icons {
    font-size: 20/375 * 100vw;
  }
  .texts {
    font-size: 12/375 * 100vw;
  }
}
</style>